package com.wtwd.campus.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wtwd.campus.entity.LocationSubmeter;

import java.util.List;

/**
 * @author mjy
 * 此服务对外提供定位分表服务
 * @date 2022/11/24
 * @description
 */
public interface LocationSubmeterService extends IService<LocationSubmeter> {


    String TABLE_NAME = "location_data_";

    /**
     * 保存定位数据
     */
    boolean save(LocationSubmeter locationSubmeter, String imei);


    /**
     * 获取数据库存储表名
     */
    String getTableName(String imei);

    /**
     * 根据设备id,以及时间获取设备轨迹
     *
     * @param deviceId
     * @param startTime
     * @param endTime
     * @return
     */
    List<LocationSubmeter> queryLocationSubmeterByDeviceIdAndTime(String tableName, Integer deviceId, long startTime, long endTime);

    /**
     * 根据imei,以及时间获取设备轨迹
     *
     * @param imei
     * @return
     */
    List<LocationSubmeter> queryLocationSubmeterByImeiAndTime(String imei, long startTime, long endTime);

    IPage<LocationSubmeter>  queryDeviceLocationPage(String tableName, Integer deviceId, Page<LocationSubmeter> page);

    /**
     * 根据时间清除分表的定位数据
     *
     * @param time
     * @return
     */
    boolean clearLocationData(long time);

    /**
     * 分页查询定位数据
     *
     * @param imei
     * @param page
     * @return
     */
    IPage<LocationSubmeter> queryDeviceLocationPageByImei(String imei, Page<LocationSubmeter> page);
}
